package itqf.dao;


import itqf.dao.impl.AddressDao;
import itqf.entity.Address;
import itqf.utils.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * com.itqf.dao
 * 2020/9/17
 */
public class AddressDaoImpl implements AddressDao {
    QueryRunner qr = new QueryRunner(DruidUtils.getDateSource());
    @Override
    public List<Address> findAllAddress(int uid) {
        String sql = "select a_id as aid,a_name as aname,a_phone as aphone,a_detail as adetail,a_state as astate from address where u_id=?";
        try {
            return qr.query(sql,new BeanListHandler<>(Address.class),uid);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
